package com.keith.foothandframe.intersystem;

import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * @author chenli
 * @date 2024/3/4 14:29
 **/
public class HelloCache {

    public static void main(String[] args) throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException {

        Class.forName("com.intersys.jdbc.CacheDriver").newInstance();

        String url = "jdbc:Cache://172.16.10.102:1972/DHC-APP";
        Driver drv = java.sql.DriverManager.getDriver(url);

        java.util.Properties props = new Properties();
        props.put("user", "WLYY");
        props.put("password", "WLYY");
        Connection dbconnection = drv.connect(url, props);

        String sql = "SELECT * FROM WLYY_VIEW_PAADM WHERE AdmDatetime BETWEEN '2024-02-01' AND '2024-02-29'";

        PreparedStatement ps = dbconnection.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        List<OfflineData> list = new ArrayList<>();
        while (rs.next()) {
            OfflineData data = new OfflineData();
            data.setCardNo(rs.getString("CardNo"));
            data.setPAADM_RowID(rs.getString("PAADM_RowID"));
            data.setID(rs.getString("ID"));
            data.setName(rs.getString("Name"));
            data.setLoc(rs.getString("loc"));
            data.setDoctor(rs.getString("Doctor"));
            data.setAdmDatetime(rs.getString("AdmDatetime"));
            data.setZD(rs.getString("ZD"));
            list.add(data);
        }
        if (list.size() > 0) {
            EasyExcel.write("C:\\Users\\zhongxiaobin\\Desktop\\offlineData.xlsx", OfflineData.class).sheet("模板").doWrite(list);
        }

    }
}
